package com.onion.core.support.utils;

import com.onion.core.entity.AbstractEntity;
import com.onion.core.entity.Modified;
import com.onion.utils.vo.Operator;

public class EntityHelper {

    /**
     * 装配操作公参【新增】
     * @param entity
     * @param operator
     */
    public static void build4Create(AbstractEntity entity, Operator operator){
        if(operator == null){
            return;
        }
        long now = System.currentTimeMillis();
        entity.setCreated(now);
        entity.setCreator(operator.getUserId());
        entity.setModified(now);
        entity.setModifier(operator.getUserId());
    }

    /**
     * 装配操作公参【修改】
     * @param entity
     * @param operator
     */
    public static void build4Modify(Modified entity, Operator operator){
        if(operator == null){
           return;
        }
        entity.setModified(System.currentTimeMillis());
        entity.setModifier(operator.getUserId());
    }

}